package com.ln.yygh.cmn.listenr;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.ln.yygh.cmn.Dict;
import com.ln.yygh.cmn.mapper.DictMapper;
import com.ln.yygh.vo.cmn.DictEeVo;
import org.springframework.beans.BeanUtils;

import java.util.Date;

/**
 * @author: lianXiaoChen
 * @create: 2021-05-26 15:13
 */
public class DictListenr extends AnalysisEventListener<DictEeVo> {

    private DictMapper dictMapper;

    public DictListenr(DictMapper dictMapper) {
        this.dictMapper = dictMapper;
    }

    //读取单行信息
    @Override
    public void invoke(DictEeVo dictEeVo, AnalysisContext analysisContext) {
        //调用有参构造添加数据库
        Dict dict = new Dict();
        dict.setCreateTime(new Date());
        dict.setUpdateTime(new Date());
        BeanUtils.copyProperties(dictEeVo, dict);
        dictMapper.insert(dict);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
